package com.jfinal.plugin.sqlbuilder;

import com.jfinal.plugin.IPlugin;
import com.jfinal.plugin.sqlbuilder.func.LikeFunction;
import org.beetl.core.Configuration;
import org.beetl.core.GroupTemplate;
import org.beetl.core.resource.StringTemplateResourceLoader;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

public class SqlBuilderPlugin implements IPlugin {

    private Configuration configuration;
    public static GroupTemplate groupTemplate;

    public static final Map<String, IFunction> FUNCTION_MAP = new HashMap<String, IFunction>();

    @Override
    public boolean start() {
        StringTemplateResourceLoader resourceLoader = new StringTemplateResourceLoader();
        try {
            configuration = Configuration.defaultConfiguration();
            groupTemplate = new GroupTemplate(resourceLoader, configuration);
            FUNCTION_MAP.put("like", new LikeFunction());
        } catch (IOException e) {
            return false;
        }
        return true;
    }

    @Override
    public boolean stop() {
        return true;
    }

}
